from django.contrib.auth.models import User
from rest_framework import serializers

from .models import Exercise


class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ('id', 'username')


class ExerciseSerializer(serializers.ModelSerializer):
    creator = UserSerializer()

    class Meta:
        model = Exercise
        fields = ('e_type', 'content', 'answer', 'creator')
        read_only_fields = ('creator',)
